package com.hz.house.controller.detail;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hz.house.bean.entity.LotteryBind;
import com.hz.house.common.ResultBean;
import com.hz.house.service.detail.KaiPanResultSearchService;
import com.hz.house.token.CurrentUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;



/**
 *  开盘相关的结果查询接口目录
 * @author lfw
 *
 */
@Api("开盘、摇号结果")
@RestController
@RequestMapping("/api/v2/result")
public class KaiPanResultSearchController {

    @Autowired
    private KaiPanResultSearchService searchService;

    /**
     *	 查询摇号结果
     * @param buildingId
     * @return
     */
    @GetMapping("/queryLotteryResult")
    @ApiOperation("查询摇号结果，orderNum:预售证号，yhType:摇号类型，刚需(necessity)普通(normal)棚改(shanty),searchWord(摇号编码或购房登记号)")
    public ResultBean queryLotteryResult(Integer page,Integer buildingId, String orderNum, String yhType, String searchWord) {
        return searchService.queryLotteryResult(page,buildingId,orderNum,yhType,searchWord);
    }

    /**
     * 	查询复核结果
     * @param buildingId
     * @return
     */
    @GetMapping("/queryVerifyResult")
    @ApiOperation("查询复核结果，orderNum:预售证号，yhType:摇号类型，刚需(necessity)普通(normal)棚改(shanty),searchWord(摇号编码或购房登记号)")
    public ResultBean queryVerifyResult(Integer page,Integer buildingId, String orderNum, String fhType,String searchWord) {
        return searchService.queryVerifyResult(page,buildingId,orderNum,fhType,searchWord);
    }

    /**
     * 	查询我的摇号
     * @param orderNum
     * @param yhNum
     * @return
     */
    @GetMapping("/findMyLottery")
    @ApiOperation("查询我的摇号，orderNum:预售证号，yhNum:摇号编码，openId:开盘id，regNum:购房登记号")
    public ResultBean findMyLottery(String orderNum,String yhNum,Integer openId,String regNum) {
        return searchService.findMyLottery(orderNum,yhNum,openId,regNum);
    }

    /**
     * 查询楼盘
     * @param buildingName
     * @return
     */
    @GetMapping("/findBuilding")
    @ApiOperation("查询楼盘及其开盘信息")
    public ResultBean findBuilding(String buildingName) {
        return searchService.findBuilding(buildingName);
    }

    /**
     * 新增我的绑定
     * @param bind
     * @return
     */
    @PostMapping("/addMyBind")
    @ApiOperation("添加我的绑定")
    public ResultBean addMyBind(@RequestBody LotteryBind bind) {
        bind.setCustomerId(CurrentUser.getCurrentUserId());
        return searchService.addMyBind(bind);
    }

    @GetMapping("/findUserBind")
    @ApiOperation(value = "获取用户所有绑定信息")
    public ResultBean findUserBind() {
        return searchService.findUserBind(CurrentUser.getCurrentUserId());
    }
}
